﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel;

namespace HA.ModFlow.Domain.DomainLayer
{
    [Serializable]
    public  class River:MFPointSC, ICloneable
    {
        public River(int i, int j, int k, int nrows, int ncolumns, int nlayers,int nPeriods)
            : base(i, j, k,nrows,ncolumns,nlayers,nPeriods)
        {
            this._stage = new List<double>();


            this._conductance = new List<double>();


            this._elevation = new List<double>();

            for (int m = 0; m < nPeriods; m++)
            {
                this._stage.Add(0);
                this._conductance.Add(0);
                this._elevation.Add(0);
                
            }

        }

        public River(int index, int nrows, int ncolumns, int nlayers,int nPeriods)
            : base(index, nrows, ncolumns, nlayers,nPeriods)
        {


            this._stage = new List<double>();


            this._conductance = new List<double>();


            this._elevation = new List<double>();

            for (int m = 0; m < nPeriods; m++)
            {
                this._stage.Add(0);
                this._conductance.Add(0);
                this._elevation.Add(0);

            }

 
        }





       




        List<double> _stage;

        public List<double> Stage
        {
            get { return _stage; }
           
        }

        public double FirstStage
        {
            get {

                return this._stage[0];
               

            }

            set
            {
                this._stage[0] = value;

              
            }
 
        }
       

        List<double> _conductance;

        public List<double> Conductance
        {
            get { return _conductance; }
           
        }


        public double FirstConductance
        {

            get
            {

                return this._conductance[0];


            }

            set
            {
                this._conductance[0] = value;
            }
 
        }




        List<double> _elevation;

        public List<double> Elevation
        {
            get { return _elevation; }

        }

        public double FirstElevation
        {


            get
            {

                return this._elevation[0];


            }

            set
            {
                this._elevation[0] = value;
            }
 
        }


        #region 公共方法


        public void UpdateValue(River river)
        {


 
        }



        public override void OnResetSperiods(int nPeriods)
        {
            base.OnResetSperiods(nPeriods);

            if (this.NPeriods==nPeriods)
	        {
                        return;
		 
	        }

            if (this.NPeriods < nPeriods)
            {
                int nSub = nPeriods - this.NPeriods;

                for (int i = 0; i < nSub; i++)
                {
                    this.Stage.Add(this.Stage[0]);
                    this.Conductance.Add(this.Conductance[0]);

                    this.Elevation.Add(this.Elevation[0]);


                }

            }

            else
            {

                int nSub =this.NPeriods- nPeriods ;


                this.Stage.RemoveRange(nPeriods, nSub);

                this.Conductance.RemoveRange(nPeriods, nSub);

                this.Elevation.RemoveRange(nPeriods, nSub);
                    
                

 

            }

            this.NPeriods = nPeriods;

        


        }
      

        #endregion




       



        public object Clone()
        {
            //River river = new River ();

            //river.Elevation.AddRange(this.Elevation);
            //river.Conductance.AddRange(this.Conductance);

            River river = (River)this.MemberwiseClone();

            river._elevation = new List<double>();
            river._conductance = new List<double>();

            river._stage = new List<double>();


            river.Elevation.AddRange(this.Elevation);

            river.Conductance.AddRange(this.Conductance);

            river.Stage.AddRange(this.Stage);

            return river;

        }
    }
}
